<%@ page language="java" import="java.util.*" pageEncoding="UTF-8" %>
<%@taglib prefix="fmt" uri="http://java.sun.com/jsp/jstl/fmt" %>
<%@taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%@taglib prefix="shiro" uri="http://shiro.apache.org/tags" %>
<!DOCTYPE html>
<html>
<head>
    <title>用户form</title>
    <%@include file="../common/include.jsp" %>
    <script type="text/javascript" src="${rc.contextPath}/js/admin/userForm.js"></script>

</head>
<body>
<div class="layui-container">
    <div class="layui-card">
        <div class="layui-card-body">
            <form class="layui-form" action="" method="post">
                <input type="hidden" id="userId" name="userId" value="${user.id}">
                <div class="layui-form-item">
                    <label class="layui-form-label">昵称</label>
                    <div class="layui-input-block">
                        <input type="text" id="nickname" name="nickname" lay-verify="required" class="layui-input" value="${user.nickname}">
                    </div>
                </div>
                <div class="layui-form-item">
                    <label class="layui-form-label">用户名</label>
                    <div class="layui-input-block">
                        <input type="text" id="userName" name="userName" lay-verify="required" class="layui-input" value="${user.userName}">
                    </div>
                </div>
                <div class="layui-form-item">
                    <label class="layui-form-label">密码</label>
                    <div class="layui-input-block">
                        <input type="text" id="password" name="password" class="layui-input"  <c:if test="${ user.id == null}">lay-verify="required"</c:if>>
                    </div>
                </div>
                <div class="layui-form-item">
                    <label class="layui-form-label">邮箱</label>
                    <div class="layui-input-block">
                        <input type="text" id="email" name="email" class="layui-input" value="${user.email}">
                    </div>
                </div>
                <div class="layui-form-item">
                    <label class="layui-form-label">性别</label>
                    <div class="layui-input-block">
                        <input type="radio" name="sex" value="0" title="男" <c:if test="${ user.sex == 0}">checked</c:if> >
                        <input type="radio" name="sex" value="1" title="女" <c:if test="${ user.sex == 1}">checked</c:if> >
                    </div>
                </div>
                <div class="layui-form-item">
                    <label class="layui-form-label">城市</label>
                    <div class="layui-input-block">
                        <input type="text" id="city" name="city" class="layui-input" value="${user.city}">
                    </div>
                </div>
                <div class="layui-form-item">
                    <label class="layui-form-label">个性签名</label>
                    <div class="layui-input-block">
                        <input type="text" id="signMsg" name="signMsg" class="layui-input" value="${user.signMsg}">
                    </div>
                </div>
                <div class="layui-form-item">
                    <label class="layui-form-label">角色</label>
                    <div class="layui-input-block" style="height: 30px">
                    <c:forEach var="role" items="${roles}" varStatus="status">
                        <c:choose>
                            <c:when test="${userRoles != null && not empty userRoles}" >
                                <c:forEach var="userRole" items="${userRoles}" varStatus="status">
                                    <input type="checkbox" name="roleId" value="${role.id}" title="${role.name}"
                                           <c:if test="${role.id == userRole.roleId}">checked</c:if> >
                                </c:forEach>
                            </c:when>
                            <c:otherwise>
                                <input type="checkbox" name="roleId" value="${role.id}" title="${role.name}">
                            </c:otherwise>
                        </c:choose>
                    </c:forEach>
                    </div>
                </div>
                <div class="layui-form-item">
                    <div class="layui-input-block">
                        <button class="layui-btn" lay-filter="addUser" lay-submit>提交</button>
                    </div>
                </div>
            </form>
        </div>
    </div>
</div>
</body>
</html>
